//
//  UserConfig.m
//  WisdomOperating
//
//  Created by john on 15/3/6.
//  Copyright (c) 2015年 john. All rights reserved.
//

#import "UserConfig.h"

static UserConfig * g_userConfig = nil;

@implementation UserConfig
{
    NSMutableDictionary *_lastSign;
}
@synthesize userConfigDic;

+ (UserConfig*)sharingUserConfig{
    if (!g_userConfig) {
        g_userConfig = [[UserConfig alloc] init];
    }
    return g_userConfig;
}

- (NSString*)getConfigFile
{
    NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString* documentsDirectory = [paths objectAtIndex:0];
    return [NSString stringWithFormat:@"%@/userConfig.plist", documentsDirectory];
}

- (id)init {
    self = [super init];
    if (self) {
        self.userConfigDic = [[NSMutableDictionary alloc] initWithContentsOfFile:[self getConfigFile]];
        _lastSign=[[NSMutableDictionary alloc]init];
        if (!self.userConfigDic) {
            self.userConfigDic = [[NSMutableDictionary alloc] initWithCapacity:10];
            [self saveConfigerData];
        }
        _ads=[[NSMutableArray alloc]init];
    }
    return self;
}

//保存配置数据
- (void)saveConfigerData {
    [self.userConfigDic writeToFile:[self getConfigFile] atomically:YES];
}

//清除配置数据
- (void)clearConfigerData
{
    NSFileManager *fileManager = [NSFileManager defaultManager];
    [fileManager removeItemAtPath:[self getConfigFile] error:nil];
}

//设置判断是否是第一次使用参数
-(void)setIfFirstTime:(NSString *)firstTime
{
    [self.userConfigDic setValue:firstTime forKey:_FIRST_TIME_];
    [self saveConfigerData];
}
//得到是否是第一次使用
-(NSString *)getIfFirstTime
{
    return (NSString *)[self.userConfigDic objectForKey:_FIRST_TIME_];
}

//设置判断是否已登录
- (void)setHaveLogin:(NSString *)login {
    [self.userConfigDic setValue:login forKey:_HAVE_Login_];
    [self saveConfigerData];

}
//得到登陆状态
- (NSString *)getHaveLogin {
    return (NSString *)[self.userConfigDic objectForKey:_HAVE_Login_];
}

//设置判断是否记住密码
- (void)setIfRememberPassWord:(NSString *)remember {
    [self.userConfigDic setValue:remember forKey:_REMEMBER_PASSWORD_];
    [self saveConfigerData];
}
//得到是否记住密码
- (NSString *)getIfRememberPassWord {
    return (NSString *)[self.userConfigDic objectForKey:_REMEMBER_PASSWORD_];
}

//设置用户名
- (void)setCurrentUserName:(NSString*)userName {
    [self.userConfigDic setValue:userName forKey:_USER_NAME_];
    [self saveConfigerData];
}

//得到当前登录用户名
- (NSString*)getCurrentUserName {
    return (NSString*)[self.userConfigDic objectForKey:_USER_NAME_];
}

//设置当前用户ID
- (void)setCurrentUserID:(NSString*)ID {
    [self.userConfigDic setValue:ID forKey:_USER_ID_];
    [self saveConfigerData];
}

//得到当前登录用户ID
- (NSString*)getCurrentuserID {
    return (NSString*)[self.userConfigDic objectForKey:_USER_ID_];
}

//设置当前用户的trueName
-(void)setCurrentTrueName:(NSString *)trueName
{
    [self.userConfigDic setValue:trueName forKey:_USER_TRUENAME_];
    [self saveConfigerData];
}
//得到当前用户的trueName
-(NSString *)getCurrentTrueName
{
    return (NSString *)[self.userConfigDic objectForKey:_USER_TRUENAME_];
}

//设置当前用户的昵称
-(void)setCurrentNickName:(NSString *)nickName
{
    [self.userConfigDic setValue:nickName forKey:_USER_NICKNAME_];
    [self saveConfigerData];
}
//得到当前用户的昵称
-(NSString *)getCurrentNickName
{
    return (NSString *)[self.userConfigDic objectForKey:_USER_NICKNAME_];
}

//设置当前用户的性别
-(void)setCurrentuserGender:(NSString *)gender
{
    [self.userConfigDic setValue:gender forKey:_USER_GENDER_];
    [self saveConfigerData];
}
//得到当前用户的性别
-(NSString *)getCurrentUserGender
{
    return (NSString *)[self.userConfigDic objectForKey:_USER_GENDER_];
}

//设置当前用户的年龄
-(void)setCurrentAge:(NSString *)age {
    [self.userConfigDic setValue:age forKey:_USER_AGE_];
    [self saveConfigerData];
}
//得到当前用户的年龄
-(NSString *)getCurrentAge {
    return (NSString *)[self.userConfigDic objectForKey:_USER_AGE_];
}


//设置当前用户的生日
-(void)setCurrentBirthday:(NSString *)birthday {
    [self.userConfigDic setValue:birthday forKey:_USER_BIRTHDAY];
    [self saveConfigerData];
}
//得到当前用户的生日
-(NSString *)getCurrentBirthday {
    return (NSString *)[self.userConfigDic objectForKey:_USER_BIRTHDAY];
}



//设置当前用户的体重
-(void)setCurrentWeight:(NSString *)weight
{
    [self.userConfigDic setValue:weight forKey:_USER_WEIGHT];
    [self saveConfigerData];
    
}
//得到当前用的的体重
-(NSString *)getCurrentWeight{
    return (NSString *)[self.userConfigDic objectForKey:_USER_WEIGHT];
}

//设置当前用户身高
-(void)setCurrentHeight:(NSString *)height
{
    [self.userConfigDic setValue:height forKey:_USER_HEIGHT];
    [self saveConfigerData];
}
//得到当前用户身高
-(NSString *)getCurrentHeight
{
    return (NSString *)[self.userConfigDic objectForKey:_USER_HEIGHT];
    
}

//设置当前登陆用户的头像
- (void)setCurrentUserHeadImage:(UIImage *)headImage
{
    NSData *imageData = UIImagePNGRepresentation(headImage);
    [self.userConfigDic setValue:imageData forKey:_USER_HEADIMAGE_];
    [self saveConfigerData];
}
//得到当前登陆用户的头像
- (UIImage *)getCurrentUserHeadImage
{
    NSData *imageData = (NSData *)[self.userConfigDic objectForKey:_USER_HEADIMAGE_];
    UIImage *headImage = [UIImage imageWithData:imageData];
    return headImage;
}

//设置当前用户的手机号码
-(void)setCurrentPhoneNum:(NSString *)phoneNum
{
    [self.userConfigDic setValue:phoneNum forKey:_USER_PHONENUM_];
    [self saveConfigerData];
}
//得到当前用户的手机号码
-(NSString *)getCurrentPhoneNum
{
    return (NSString *)[self.userConfigDic objectForKey:_USER_PHONENUM_];
}

//设置当前用户的密码
- (void)setCurrentUserPsd:(NSString*)userPsd {
    [self.userConfigDic setValue:userPsd forKey:_USER_PASSWORD_];
    [self saveConfigerData];
}

//得到当前用户的密码
- (NSString*)getCurrentUserPsd {
    return (NSString*)[self.userConfigDic objectForKey:_USER_PASSWORD_];
}

//设置头像string
-(void)setcurrentHeadImage:(NSString *)headImage
{
    [self.userConfigDic setValue:headImage forKey:_USER_HEADIMAGE_];
    [self saveConfigerData];
}
//得到当前用户头像
-(NSString *)getCurrentHeadImage
{
    return (NSString *)[self.userConfigDic objectForKey:_USER_HEADIMAGE_];
}

//设置等级
-(void)setcurrentLevel:(NSString *)level
{
    [self.userConfigDic setValue:level forKey:_USER_LEVEL_];
    [self saveConfigerData];
}
//得到等级
-(NSString *)getCurrentLevel
{
    return (NSString *)[self.userConfigDic objectForKey:_USER_LEVEL_];
}



//设置用户头像data类型数据
- (void)setUserHeadData:(NSData *)headData
{
    [self.userConfigDic setValue:headData forKey:_HEAD_DATA_];
    [self saveConfigerData];
}
//得到用户data类型数据
- (NSData *)getUserHeadData {
    return (NSData *)[self.userConfigDic objectForKey:_HEAD_DATA_];
}

//无key写入存储
-(void)setBlueToothKey:(NSMutableData *)blueKey
{
    [self.userConfigDic setValue:blueKey forKey:_USER_BLUETOOTHKEY_];
    [self saveConfigerData];
    
}
//得到key
-(NSMutableData *)getBluetoothKey
{
    return (NSMutableData *)[self.userConfigDic objectForKey:_USER_BLUETOOTHKEY_];
}

//设置蓝牙的物理地址
-(void) setBluetoothAddress:(NSString *)address
{
    [self.userConfigDic setValue:address forKey:_USER_BLUETOOTH_ADDRESS_];
    [self saveConfigerData];
}
//得到蓝牙的物理地址
-(NSString *) getBluetoothAddress
{
    return (NSString *)[self.userConfigDic objectForKey:_USER_BLUETOOTH_ADDRESS_];
}


//设置token
-(void)setToken:(NSString *)token
{
    [self.userConfigDic setValue:token forKey:_USER_TOKEN_];
}
//得到token
-(NSString *)getToken
{
    return (NSString *)[self.userConfigDic objectForKey:_USER_TOKEN_];
}

//临时存睡眠报告
//设置报告
-(void) setSleep:(NSData *)sleepData
{
    [self.userConfigDic setValue:sleepData forKey:_USER_SLEEP_];
    [self saveConfigerData];
}
//得到报告
-(NSData *)getSleep
{
    return (NSData *)[self.userConfigDic objectForKey:_USER_SLEEP_];
}

//设置睡眠改善是否开启
- (void)setSleepImprove:(BOOL)isOK
{
    if (isOK)
    {//如果开启了睡眠改善
        [self.userConfigDic setValue:@"sleepImprove" forKey:_USER_SLEEP_IMPROVE];
    }
    else
    {
        [self.userConfigDic setValue:@"no" forKey:_USER_SLEEP_IMPROVE];
    }
    [self saveConfigerData];
}

//得到睡眠改善是否开启BOOL
- (BOOL)isSleepImprove
{
    NSString * string = (NSString *)[self.userConfigDic objectForKey:_USER_SLEEP_IMPROVE];
    if ([string isEqualToString:_USER_SLEEP_IMPROVE]) {
        return YES;
    }else{
        return NO;
    }
}

//设置睡眠改善是否开启(睡眠报告展示)
- (void)setSleepImproveShow:(BOOL)isOK
{
    if (isOK)
    {//如果开启了睡眠改善
        [self.userConfigDic setValue:@"sleepImproveShow" forKey:_USER_SLEEP_IMPROVE_SHOW];
    }
    else
    {
        [self.userConfigDic setValue:@"no" forKey:_USER_SLEEP_IMPROVE_SHOW];
    }
    [self saveConfigerData];
}
//得到睡眠改善是否开启BOOL(睡眠报告展示)
- (BOOL)isSleepImproveShow
{
    NSString * string = (NSString *)[self.userConfigDic objectForKey:_USER_SLEEP_IMPROVE_SHOW];
    if ([string isEqualToString:_USER_SLEEP_IMPROVE_SHOW]) {
        return YES;
    }else{
        return NO;
    }
}

//设置梦境控制是否开启
- (void)setDreamImprove:(BOOL)isOK
{
    if (isOK)
    {//如果开启了睡眠改善
        [self.userConfigDic setValue:@"dreamImprove" forKey:_USER_DREAM_IMPROVE];
    }
    else
    {
        [self.userConfigDic setValue:@"no" forKey:_USER_DREAM_IMPROVE];
    }
    [self saveConfigerData];
}

//得到梦境控制是否开启BOOL
- (BOOL)isDreamImprove
{
    NSString * string = (NSString *)[self.userConfigDic objectForKey:_USER_DREAM_IMPROVE];
    if ([string isEqualToString:_USER_DREAM_IMPROVE]) {
        return YES;
    }else{
        return NO;
    }
}

//设置梦境控制是否开启(睡眠报告展示)
- (void)setDreamImproveShow:(BOOL)isOK
{
    if (isOK)
    {//如果开启了睡眠改善
        [self.userConfigDic setValue:@"dreamImproveShow" forKey:_USER_DREAM_IMPROVE_SHOW];
    }
    else
    {
        [self.userConfigDic setValue:@"no" forKey:_USER_DREAM_IMPROVE_SHOW];
    }
    [self saveConfigerData];
}
/*
 得到梦境控制是否开启BOOL(睡眠报告展示)
 */
- (BOOL)isDreamImproveShow
{
    NSString * string = (NSString *)[self.userConfigDic objectForKey:_USER_DREAM_IMPROVE_SHOW];
    if ([string isEqualToString:_USER_DREAM_IMPROVE_SHOW]) {
        return YES;
    }else{
        return NO;
    }
}

//设置报告开始时间  HH:mm
-(void)setReportStartTime:(NSString *)reportTime
{
    [self.userConfigDic setValue:reportTime forKey:_USER_REPOR_TTIME_];
    [self saveConfigerData];
}
//得到报告开始时间 HH:mm
-(NSString *)getReportStartTime
{
    NSString * string = (NSString *)[self.userConfigDic objectForKey:_USER_REPOR_TTIME_];
    return [TJJDefines isNull:string]?@"00:00":string;
}

//设置报告开始时间  nsdate 格式
-(void)setReportStartTimeTypeDate:(NSString *)reportTime
{
    [self.userConfigDic setValue:reportTime forKey:_USER_REPOR_TIME_TYPEDATE];
    [self saveConfigerData];
}
//得到报告开始时间 nsdate 格式
-(NSString *)getReportStartTimeTypeDate
{
    NSString * string = (NSString *)[self.userConfigDic objectForKey:_USER_REPOR_TIME_TYPEDATE];
    return [TJJDefines isNull:string]?@"1970-01-01 00:00:00":string;
}

//设置睡眠得分
-(void)setSleepScore:(NSString *)score
{
    [self.userConfigDic setValue:score forKey:_USER_SLEEP_SCORE_];
    [self saveConfigerData];
}
//获取睡眠得分
-(NSString *)getSleepScore
{
    NSString * string = (NSString *)[self.userConfigDic objectForKey:_USER_SLEEP_SCORE_];
    return [TJJDefines isNull:string]?@"0":string;
}

//设置深睡时间
-(void)setsleepShenShuiTime:(NSString *)myTime
{
    [self.userConfigDic setValue:myTime forKey:_USER_SLEEP_SHENSHUI_];
    [self saveConfigerData];
}
//得到深睡时间
-(NSString *)getSleepShenShuiTime
{
//    return (NSString *)[self.userConfigDic objectForKey:_USER_SLEEP_SHENSHUI_];
    NSString * string = (NSString *)[self.userConfigDic objectForKey:_USER_SLEEP_SHENSHUI_];
    return [TJJDefines isNull:string]?@"00":string;
}

//设置做梦时间
-(void)setDreamTime:(NSString *)myTime
{
    [self.userConfigDic setValue:myTime forKey:_USER_DREAM_TIME_];
    [self saveConfigerData];
}
//得到做梦时间
-(NSString *)getDreamTime
{
//    return (NSString *)[self.userConfigDic objectForKey:_USER_DREAM_TIME_];
    NSString * string = (NSString *)[self.userConfigDic objectForKey:_USER_DREAM_TIME_];
    return [TJJDefines isNull:string]?@"00":string;
}

//设置睡眠时间
-(void)setSLeepTime:(NSString *)myTime
{
    [self.userConfigDic setValue:myTime forKey:_USER_SLEEP_TIME];
    [self saveConfigerData];
}
//得到睡眠时间
-(NSString *)getSleepTime
{
    return (NSString *)[self.userConfigDic objectForKey:_USER_SLEEP_TIME];
//    NSString * string = (NSString *)[self.userConfigDic objectForKey:_USER_SLEEP_TIME];
//    return [TJJDefines isNull:string]?@"0":string;
}



//设置周日标记
-(void) setSundayMark:(NSString *)Sunday
{
    [self.userConfigDic setValue:Sunday forKey:_USER_AUTO_SUNDAY];
    [self saveConfigerData];
}
//得到周日标记
-(NSString *)getSundayMark
{
    return (NSString *)[self.userConfigDic objectForKey:_USER_AUTO_SUNDAY];
}


//自然唤醒的掩码
-(void) setAlarmMask:(NSNumber *)weekmask
{
    [self.userConfigDic setValue:weekmask forKey:_ALARM_WEEK_MASK];
    [self saveConfigerData];
}
-(NSNumber *) getAlarmMask
{
    return (NSNumber *) [self.userConfigDic objectForKey:_ALARM_WEEK_MASK];
}
//设置周1标记
-(void) setMondayMark:(NSString *)Monday
{
    [self.userConfigDic setValue:Monday forKey:_USER_AUTO_MONDAY];
    [self saveConfigerData];

}
//得到周1标记
-(NSString *)getMondayMark
{
       return (NSString *)[self.userConfigDic objectForKey:_USER_AUTO_MONDAY];
}

//设置周2标记
-(void) setTuesdayMark:(NSString *)Tuesday
{
    [self.userConfigDic setValue:Tuesday forKey:_USER_AUTO_TUESDAY];
    [self saveConfigerData];
}
//得到周2标记
-(NSString *)getTuesdayMark
{
    return (NSString *)[self.userConfigDic objectForKey:_USER_AUTO_TUESDAY];
}

//设置周3标记
-(void) setWednesdayMark:(NSString *)Wednesday
{
    [self.userConfigDic setValue:Wednesday forKey:_USER_AUTO_WEDNESDAY];
    [self saveConfigerData];
}
//得到周3标记
-(NSString *)getWednesdayMark
{
    return (NSString *)[self.userConfigDic objectForKey:_USER_AUTO_WEDNESDAY];
}

//设置周4标记
-(void) setThursdayMark:(NSString *)Thursday
{
    [self.userConfigDic setValue:Thursday forKey:_USER_AUTO_THURSDAY];
    [self saveConfigerData];
}
//得到周4标记
-(NSString *)getThursdayMark
{
    return (NSString *)[self.userConfigDic objectForKey:_USER_AUTO_THURSDAY];
}

//设置周5标记
-(void) setFridayMark:(NSString *)Friday
{
    [self.userConfigDic setValue:Friday forKey:_USER_AUTO_FRIDAY];
    [self saveConfigerData];
}
//得到周5标记
-(NSString *)getFridayMark
{
     return (NSString *)[self.userConfigDic objectForKey:_USER_AUTO_FRIDAY];
}

//设置周6标记
-(void) setSaturdayMark:(NSString *)Saturday
{
    [self.userConfigDic setValue:Saturday forKey:_USER_AUTO_SATURDAY];
    [self saveConfigerData];
}
//得到周6标记
-(NSString *)getSaturdayMark
{
    return (NSString *)[self.userConfigDic objectForKey:_USER_AUTO_SATURDAY];
}

//设置智能唤醒时间（重复）单位是秒
-(void)setAutoTime:(NSNumber *)Time
{
    [self.userConfigDic setValue:Time forKey:_USER_AUTO_TIME];
    [self saveConfigerData];
}
//得到智能唤醒时间（重复）
-(NSNumber *)getAutoTime
{
    return (NSNumber *)[self.userConfigDic objectForKey:_USER_AUTO_TIME];
}

//设定自然唤醒的时刻(重复)
-(void)setStartalarmTime:(NSNumber *)Time
{
    [self.userConfigDic setValue:Time forKey:_SET_TIME_TIME];
    [self saveConfigerData];
}
//得到设置智能唤醒的时刻(重复)
-(NSNumber *)getStartalarmTime
{
    return (NSNumber *)[self.userConfigDic objectForKey:_SET_TIME_TIME];
}


//设置状态
-(void)setJudgeCool:(NSString *)Cool
{
    [self.userConfigDic setValue:Cool forKey:_USER_JUDGE_COOL];
    [self saveConfigerData];
}
//得到状态
-(NSString *)getJudgeCool
{
    return (NSString *)[self.userConfigDic objectForKey:_USER_JUDGE_COOL];
}

//设置睡眠模式开启时间
-(void)setSleepStartTime:(NSString *)Time
{
    [self.userConfigDic setValue:Time forKey:_USER_SLEEP_START_TIME];
    [self saveConfigerData];
}
//得到睡眠模式开启时间
-(NSString *)getSleepStartTime
{
    return (NSString *)[self.userConfigDic objectForKey:_USER_SLEEP_START_TIME];
}


//设置睡眠模式关闭时间
-(void)setSleepEndTime:(NSString *)Time
{
    [self.userConfigDic setObject:Time forKey:_USER_SLEEP_END_TIME];
    [self saveConfigerData];
}
//得到睡眠模式关闭时间
-(NSString *)getSleepEndTime
{
    return (NSString *)[self.userConfigDic objectForKey:_USER_SLEEP_END_TIME];
}
//设置睡眠关机时间标记
- (void)setHadSetEndTime:(BOOL)isOK
{
    if (isOK)
    {
        [self.userConfigDic setObject:@"sleepEndTimeMark" forKey:_USER_SLEEP_END_TIME_MARK];
    }
    else
    {
        [self.userConfigDic setObject:@"no" forKey:_USER_SLEEP_END_TIME_MARK];
    }
    [self saveConfigerData];
}
//获取睡眠关机时间标记
- (BOOL)getHadSetEndTime
{
    NSString * string = (NSString *)[self.userConfigDic objectForKey:_USER_SLEEP_END_TIME_MARK];
    if([TJJDefines isNull:string])
    {//这边默认是NO，标识之前没有上传失败的睡眠报告
        return NO;
    }
    else
    {
        if ([string isEqualToString:_USER_SLEEP_END_TIME_MARK])
        {
            return YES;
        }
        else
        {
            return NO;
        }
    }
}

//上一次睡眠的小时
-(void)setLastHour:(NSString *)Hour
{
    [self.userConfigDic setObject:Hour forKey:_USER_SLEEP_LAST_HOUR];
    [self saveConfigerData];
}
//得到上一次睡眠的小时
-(NSString *)getLastHour
{
    return (NSString *)[self.userConfigDic objectForKey:_USER_SLEEP_LAST_HOUR];
}
//上一次睡眠的分钟
-(void)setLastMinute:(NSString *)Minute
{
    [self.userConfigDic setObject:Minute forKey:_USER_SLEEP_LAST_MINUTE];
    [self saveConfigerData];
}
//得到上一次睡眠的小时
-(NSString *)getLastMinute
{
    return (NSString *)[self.userConfigDic objectForKey:_USER_SLEEP_LAST_MINUTE];
}

//上一次睡眠的秒数
-(void)setLastSec:(NSString *)Sec
{
    [self.userConfigDic setObject:Sec forKey:_USER_SLEEP_LAST_SEC];
    [self saveConfigerData];
}
//得到上一次睡眠的秒数
-(NSString *)getLastSec
{
    return  (NSString *)[self.userConfigDic objectForKey:_USER_SLEEP_LAST_SEC];
}

//设置 智能唤醒弹框被关闭了没(1,关。0，nil 继续弹出)
-(void) setJudgeTestingSwitch:(NSString *)Switch{
    [self.userConfigDic setObject:Switch forKey:_USER_DREAM_SWITCH];
    [self saveConfigerData];
}

//得到智能唤醒弹框开关状态
-(NSString *)getJudgeTestingSwitch
{
    return (NSString *)[self.userConfigDic objectForKey:_USER_DREAM_SWITCH];
}

//设置应用被杀前的时间
-(void) setStopwatchTime:(NSString *)time
{
    [self.userConfigDic setObject:time forKey:_USER_STOPWATCHTIME];
    [self saveConfigerData];
}
//得到应用被杀前的时间
-(NSString *) getStopwatchTime
{
    return (NSString *)[self.userConfigDic objectForKey:_USER_STOPWATCHTIME];
}

//设置绑定状态
- (void) setConnectCool:(NSString *)cool
{
    [self.userConfigDic setObject:cool forKey:_USER_CONNECTCOOL];
    [self saveConfigerData];
}
//得到绑定状态
-(NSString *)getConnectCool
{//YES 标识绑定。NO标识未进行设备绑定
    return (NSString *)[self.userConfigDic objectForKey:_USER_CONNECTCOOL];
}

//今天闹钟有没有执行过标记(记录日期)
- (void) setTodayAlarmClockCarryOutMark:(NSString *)Mark
{
    [self.userConfigDic setObject:Mark forKey:_USER_TODAYALARMCLOCKMARK];
    [self saveConfigerData];
}
//得到标记
- (NSString *)gettodayAlarmClockCarryOutMark
{
    return (NSString *)[self.userConfigDic objectForKey:_USER_TODAYALARMCLOCKMARK];
}

//设置智能唤醒小憩时间
-(void) setAutoXiaoQiTime:(NSNumber *)time
{
    [self.userConfigDic setObject:time forKey:_USER_AUTOXIAOQITIME];
    [self saveConfigerData];
}
//得到智能唤醒小憩时间
-(NSNumber *) getAutoXiaoQiTime
{
    return (NSNumber *)[self.userConfigDic objectForKey:_USER_AUTOXIAOQITIME];
}

//设置智能唤醒小时的函数
-(void) setCurrentAutoHourRow:(NSString *)Row
{
    [self.userConfigDic setObject:Row forKey:_USER_AUTOHOURROW];
    [self saveConfigerData];
}
//得到智能唤醒小时的函数
-(NSString *)getCUrrentAutoHourRow
{
    NSString * string = (NSString *)[self.userConfigDic objectForKey:_USER_AUTOHOURROW];
    return  [TJJDefines isNull:string]?@"0":string;
}

//设置智能唤醒分钟的函数
-(void) setCurrentAutoMinRow:(NSString *)Row
{
    [self.userConfigDic setObject:Row forKey:_USER_AUTOMINROW];//SXW__崩溃标记
    [self saveConfigerData];
}

//得到智能唤醒分钟的函数
-(NSString *) getCurrentAutoMinRow
{
    NSString * string = (NSString *)[self.userConfigDic objectForKey:_USER_AUTOMINROW];
    return [TJJDefines isNull:string]?@"0":string;
}

//第一次登陆状态
-(void) setFirstLoginCool:(NSString *)cool
{//如果第一次登录 1  标识已经不是第一次使用。 0 标识第一次安装使用，控制用户指导图层的出现
    [self.userConfigDic setObject:cool forKey:_FIRST_COOL];
    [self saveConfigerData];
}

//得到登陆状态
- (NSString *) getFirstLoginCool
{
    return (NSString *)[self.userConfigDic objectForKey:_FIRST_COOL];
}

//设置固件版本
- (void)setHardware:(NSString *)hardware
{
    [self.userConfigDic setObject:hardware forKey:_USER_HARDWARE];
    [self saveConfigerData];
   
}

//获得固件版本
- (NSString *)getHardware
{
    return (NSString *)[self.userConfigDic objectForKey:_USER_HARDWARE];
}

//设置蓝牙适配器版本
- (void)setBLEHardware:(NSString *)bleHardware
{
    [self.userConfigDic setObject:bleHardware forKey:_USER_BLEHARDWARE];
    [self saveConfigerData];
    
}

//获得蓝牙适配器版本
- (NSString *)getBLEHardware
{
    return (NSString *)[self.userConfigDic objectForKey:_USER_BLEHARDWARE];
}

//设置应用新版本下载地址
- (void)setSoftwareURL:(NSString *)url
{
    
    [self.userConfigDic setObject:url forKey:_USER_SOFTWAREURL];
    [self saveConfigerData];
}

//获得应用新版本下载地址
- (NSString *)getSoftwareURL
{
    return (NSString *)[self.userConfigDic objectForKey:_USER_SOFTWAREURL];
}


//设置序列号
- (void)setSerialNumber:(NSString *)serialNumber
{
    [self.userConfigDic setObject:serialNumber forKey:_USER_SERIALNUMBER];
    [self saveConfigerData];
}
//得到序列号
- (NSString *)getSerialNumber
{
    return (NSString *)[self.userConfigDic objectForKey:_USER_SERIALNUMBER];
}

//标记是否是第一次使用梦境控制，如果是第一次，那么存储特定字符串。宏定义中有。
- (void)setFirstDreemingControl:(NSString *)stringDreem
{
    [self.userConfigDic setObject:stringDreem forKey:_FIRSTDREEMINGCONTROL];
    [self saveConfigerData];
}

//得到是否第一次使用梦境控制，BOOL
- (BOOL)isFirstDreemingControl
{
    NSString * string = (NSString *)[self.userConfigDic objectForKey:_FIRSTDREEMINGCONTROL];
    if ([string isEqualToString:FIRSTDREEMINGCONTROL]) {
        return NO;
    }else{
        return YES;
    }
}

//标记是否是第一次开启睡眠模式，如果是第一次，那么存储特定字符串。宏定义中有。
- (void)setFirstUseSleep:(NSString *)stringSleep
{
    [self.userConfigDic setObject:stringSleep forKey:_FIRSTUSESLEEP];
    [self saveConfigerData];
}

//得到是否第一次使用睡眠模式，BOOL
- (BOOL)isFirstUseSleep
{
    NSString * string = (NSString *)[self.userConfigDic objectForKey:_FIRSTUSESLEEP];
    if ([string isEqualToString:FIRSTUSESLEEP]) {
        return NO;
    }else{
        return YES;
    }
}

//睡眠报告上传标志。默认是NO。
- (void)setSubmitSleepMark:(BOOL)isYes
{
    if (isYes)
    {//设置yes
        [self.userConfigDic setObject:@"markSleepDataSubmit" forKey:_MARK_SLEEPDATA_SUBMIT];
    }
    else
    {
        [self.userConfigDic setObject:@"00" forKey:_MARK_SLEEPDATA_SUBMIT];
    }
    [self saveConfigerData];
}

//得到睡眠报告上传标志,如果最近的一次有分数的报告已经上传了，为YES，否则为NO.
- (BOOL)getSubmitSleepMark
{
    NSString * string = (NSString *)[self.userConfigDic objectForKey:_MARK_SLEEPDATA_SUBMIT];
    if([TJJDefines isNull:string])
    {//如果是空对象。说明还没有运行过上传的代码，这边默认是yes，标识之前没有上传失败的睡眠报告
        return YES;
    }
    else
    {
        if ([string isEqualToString:_MARK_SLEEPDATA_SUBMIT])
        {
            return YES;
        }
        else
        {
            return NO;
        }
    }
}

//睡眠报告上传数据字典
- (void)setSubmitSleepData:(NSDictionary *)dataDic
{
    [self.userConfigDic setObject:dataDic forKey:_SLEEPDATA_SUBMIT];
    [self saveConfigerData];
}
//得到睡眠报告上传数据字典.
- (NSDictionary *)getSubmitSleepData
{
    NSDictionary * dic = [self.userConfigDic objectForKey:_SLEEPDATA_SUBMIT];
    if ([TJJDefines isNull:dic])
    {//如果是空对象
        return nil;
    }
    else
    {
        return  dic;
    }
}

//睡眠报告上传数据字典状态
- (void)setSubmitSleepDataState:(NSDictionary *)dataDic
{
    [self.userConfigDic setObject:dataDic forKey:_SLEEPDATASTATE_SUBMIT];
    [self saveConfigerData];
}
//得到睡眠报告上传数据字典状态
- (NSDictionary *)getSubmitSleepDataState
{
    NSDictionary * dic = [self.userConfigDic objectForKey:_SLEEPDATASTATE_SUBMIT];
    if ([TJJDefines isNull:dic])
    {//如果是空对象
        return nil;
    }
    else
    {
        return  dic;
    }
}

//本地推送的图片加载地址
- (void)setImageURL:(NSString *)url
{
    [self.userConfigDic setObject:url forKey:_PUSH_IMAGE_URL];
    [self saveConfigerData];
}
//获取本地推送的图片记载的地址
- (NSString *)getImageURL
{
    return (NSString *)[self.userConfigDic objectForKey:_PUSH_IMAGE_URL];
}
//设置本地推送对应的链接
- (void)setPushURL:(NSString *)url
{
    [self.userConfigDic setObject:url forKey:_PUSH_URL];
    [self saveConfigerData];
}
//获取本地推送对应的链接
- (NSString *)getPushURL
{
    return (NSString *)[self.userConfigDic objectForKey:_PUSH_URL];

}

//保存背景圆环的状态（本地推送的时候需要用到）
- (void)setbackShapeHidden:(BOOL)YESORNO
{
    if (YESORNO)
    {//设置yes
        [self.userConfigDic setObject:@"shapeback" forKey:_SHAPE_BACK];
    }
    else
    {
        [self.userConfigDic setObject:@"00" forKey:_SHAPE_BACK];
    }
    [self saveConfigerData];
}
//得到背景圆环的状态（本地推送的时候需要用到）
- (BOOL)getbackShapeHidden
{
    NSString * string = (NSString *)[self.userConfigDic objectForKey:_SHAPE_BACK];
    if([TJJDefines isNull:string])
    {//如果是空对象。说明还没有运行过上传的代码，这边默认是yes，标识之前没有上传失败的睡眠报告
        return NO;
    }
    else
    {
        if ([string isEqualToString:_SHAPE_BACK])
        {
            return YES;
        }
        else
        {
            return NO;
        }
    }
}
//保存加载圆环的状态（本地推送的时候需要用到）
- (void)setfrontShapeHidden:(BOOL)YESORNO
{
    if (YESORNO)
    {//设置yes
        [self.userConfigDic setObject:@"shapefront" forKey:_SHAPE_FRONT];
    }
    else
    {
        [self.userConfigDic setObject:@"00" forKey:_SHAPE_FRONT];
    }
    [self saveConfigerData];
}
//得到加载圆环的状态（本地推送的时候需要用到）
- (BOOL)getfrontShapeHidden
{
    NSString * string = (NSString *)[self.userConfigDic objectForKey:_SHAPE_FRONT];
    if([TJJDefines isNull:string])
    {//如果是空对象。说明还没有运行过上传的代码，这边默认是yes，标识之前没有上传失败的睡眠报告
        return NO;
    }
    else
    {
        if ([string isEqualToString:_SHAPE_FRONT])
        {
            return YES;
        }
        else
        {
            return NO;
        }
    }
}

//保存睡眠按钮的状态（本地推送的时候需要用到）
- (void)setsleepBthHidden:(BOOL)YESORNO
{
    if (YESORNO)
    {//设置yes
        [self.userConfigDic setObject:@"sleepBth" forKey:_PUSH_BUTTON_SLEEP];
    }
    else
    {
        [self.userConfigDic setObject:@"00" forKey:_PUSH_BUTTON_SLEEP];
    }
    [self saveConfigerData];

}
//得到睡眠按钮的状态（本地推送的时候需要用到）
- (BOOL)getsleepBthHidden
{
    NSString * string = (NSString *)[self.userConfigDic objectForKey:_PUSH_BUTTON_SLEEP];
    if([TJJDefines isNull:string])
    {//如果是空对象。说明还没有运行过上传的代码，这边默认是yes，标识之前没有上传失败的睡眠报告
        return NO;
    }
    else
    {
        if ([string isEqualToString:_PUSH_BUTTON_SLEEP])
        {
            return YES;
        }
        else
        {
            return NO;
        }
    }
}
//保存小憩睡眠按钮的状态（本地推送的时候需要用到）
- (void)setScoreButtonHidden:(BOOL)YESORNO
{
    if (YESORNO)
    {//设置yes
        [self.userConfigDic setObject:@"ScoreButton" forKey:_PUSH_BUTTON_SCORE];
    }
    else
    {
        [self.userConfigDic setObject:@"00" forKey:_PUSH_BUTTON_SCORE];
    }
    [self saveConfigerData];
}
//得到小憩睡眠按钮的状态（本地推送的时候需要用到）
- (BOOL)getScoreButtonHidden
{
    NSString * string = (NSString *)[self.userConfigDic objectForKey:_PUSH_BUTTON_SCORE];
    if([TJJDefines isNull:string])
    {//如果是空对象。说明还没有运行过上传的代码，这边默认是yes，标识之前没有上传失败的睡眠报告
        return NO;
    }
    else
    {
        if ([string isEqualToString:_PUSH_BUTTON_SCORE])
        {
            return YES;
        }
        else
        {
            return NO;
        }
    }
}
//保存关闭睡眠报告按钮的状态（本地推送的时候需要用到）
- (void)setmonitorBthHidden:(BOOL)YESORNO
{
    if (YESORNO)
    {//设置yes
        [self.userConfigDic setObject:@"monitorBth" forKey:_PUSH_BUTTON_MONITOR];
    }
    else
    {
        [self.userConfigDic setObject:@"00" forKey:_PUSH_BUTTON_MONITOR];
    }
    [self saveConfigerData];
}

//得到关闭睡眠报告按钮的状态（本地推送的时候需要用到）
- (BOOL)getmonitorBthHidden
{
    NSString * string = (NSString *)[self.userConfigDic objectForKey:_PUSH_BUTTON_MONITOR];
    if([TJJDefines isNull:string])
    {//如果是空对象。说明还没有运行过上传的代码，这边默认是yes，标识之前没有上传失败的睡眠报告
        return NO;
    }
    else
    {
        if ([string isEqualToString:_PUSH_BUTTON_MONITOR])
        {
            return YES;
        }
        else
        {
            return NO;
        }
    }
}

//保存是否处于固件升级的状态
- (void)setUpdateHardWare:(BOOL)YESORNO
{
    if (YESORNO)
    {//设置yes
        [self.userConfigDic setObject:@"updatehardware" forKey:_UPDATE_HARDWARE];
    }
    else
    {
        [self.userConfigDic setObject:@"00" forKey:_UPDATE_HARDWARE];
    }
    [self saveConfigerData];
}

//得到是否处于固件升级的状态
- (BOOL)getUpdateHardWare
{
    NSString * string = (NSString *)[self.userConfigDic objectForKey:_UPDATE_HARDWARE];
    if([TJJDefines isNull:string])
    {//如果是空对象。说明还没有运行过上传的代码，这边默认是yes，标识之前没有上传失败的睡眠报告
        return NO;
    }
    else
    {
        if ([string isEqualToString:_UPDATE_HARDWARE])
        {
            return YES;
        }
        else
        {
            return NO;
        }
    }
}


//保存固件升级的下载地址
- (void)setUpdateHardWareDownURL:(NSString *)url
{
    [self.userConfigDic setObject:url forKey:_UPDATE_HARDWARE_DOWN_URL];
    [self saveConfigerData];
}

//得到固件升级的下载地址
- (NSString *)getUpdateHardWareDownURL
{
    NSString * string = (NSString *)[self.userConfigDic objectForKey:_UPDATE_HARDWARE_DOWN_URL];
    if([TJJDefines isNull:string])
    {//如果是空对象。说明还没有运行过上传的代码
        return @"0";
    }
    else
    {
        return string;
    }
}

//保存固件升级包的本地地址
- (void)setUpdateHardWareDownURLLocal:(NSString *)path
{
    [self.userConfigDic setObject:path forKey:_UPDATE_HARDWARE_DOWN_URL_LOCAL];
    [self saveConfigerData];
}

//得到固件升级包的本地地址
- (NSString *)getUpdateHardWareDownURLLocal
{
    NSString * path = (NSString *)[self.userConfigDic objectForKey:_UPDATE_HARDWARE_DOWN_URL_LOCAL];
    if([TJJDefines isNull:path])
    {//如果是空对象。说明还没有运行过上传的代码
        return @"0";
    }
    else
    {
        return path;
    }
}

//设置固件版本 比如1.2（网络上的版本）
- (void)setHardwareNumber:(NSString *)number
{
    [self.userConfigDic setObject:number forKey:_HARDWARENUMBERNEW];
    [self saveConfigerData];
}
//得到固件版本 比如1.2（网络上的版本）
- (NSString *)getHardwareNumber
{
    NSString * number = (NSString *)[self.userConfigDic objectForKey:_HARDWARENUMBERNEW];
    if([TJJDefines isNull:number])
    {//如果是空对象。说明还没有运行过上传的代码
        return @"0";
    }
    else
    {
        return number;
    }
}

//设置标记，标记Home界面是否接收43 15 等字符串。因为固件升级之后，会有乱码，会影响到这个再一次判断。初始化是NO,升级成功之后是YES



//保存 绑定界面 检测是否是1.4版本以上的  在读取硬件版本号之后弄的  1.4版本之后，不发送key也是可以的。
- (void)setMarkNewNoSendKey:(BOOL)YESORNO
{
    if (YESORNO)
    {//设置yes   _SENDNOKEY @"sendnokey"
        [self.userConfigDic setObject:@"sendnokey" forKey:_SENDNOKEY];
    }
    else
    {
        [self.userConfigDic setObject:@"00" forKey:_SENDNOKEY];
    }
    [self saveConfigerData];
}
//得到绑定界面 检测是否是1.4版本以上的  在读取硬件版本号之后弄的  1.4版本之后，不发送key也是可以的。
- (BOOL)getMarkNewNoSendKey
{
    NSString * string = (NSString *)[self.userConfigDic objectForKey:_SENDNOKEY];
    if([TJJDefines isNull:string])
    {//如果是空对象。说明还没有运行过上传的代码，这边默认是yes，标识之前没有上传失败的睡眠报告
        return NO;
    }
    else
    {
        if ([string isEqualToString:_SENDNOKEY])
        {
            return YES;
        }
        else
        {
            return NO;
        }
    }
}


@end
